from Box import Box
from Person import Person
import pygame
import UAI

class Game:
    items = []
    def __init__(self):
        pass
        
    def run(self):
        for item in self.items:
            item.run()
        self.collisionTesting()
        
    def collisionTesting(self):
        movables = self.getMovableObjects()
        for movable in movables:
            i = movable.rect.collidelist(movables)
            if not movable == movables[i]:
                if i > -1:
                    movable.collision()
                
    def draw(self):
        for item in self.items:
            item.draw()
    
    def addItem(self, item):
        self.items.append(item)
    
    def getMovableObjects(self):
        items = []
        for item in self.items:
            if item.movable:
                items.append(item)
        return items
    
    def getNonMovableObjects(self):
        items = []
        for item in self.items:
            if not item.movable:
                items.append(item)
        return items
    
    def getTeamMembers(self, team):
        teamMembers = []
        for item in self.items:
            if item.name == 'Person':
                if item.team == team:
                    teamMembers.append(item)
        return teamMembers